package com.blb.marrysystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.marrysystem.dao.TbPackageDao;
import com.blb.marrysystem.entity.TbPackage;
import com.blb.marrysystem.service.TbPackageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (TbPackage)表服务实现类
 *
 * @author makejava
 * @since 2023-01-11 09:22:32
 */
@Service
public class TbPackageServiceImpl implements TbPackageService {
    @Resource
    private TbPackageDao tbPackageDao;

    /**
     * 通过ID查询单条数据
     *
     * @param packageId 主键
     * @return 实例对象
     */
    @Override
    public TbPackage queryById(Integer packageId) {
        return this.tbPackageDao.queryById(packageId);
    }

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @Override
    public Page<TbPackage> queryByPage() {
        return null;
    }

    /**
     * 新增数据
     *
     * @param tbPackage 实例对象
     * @return 实例对象
     */
    @Override
    public TbPackage insert(TbPackage tbPackage) {
        this.tbPackageDao.insert(tbPackage);
        return tbPackage;
    }

    /**
     * 修改数据
     *
     * @param tbPackage 实例对象
     * @return 实例对象
     */
    @Override
    public TbPackage update(TbPackage tbPackage) {
        this.tbPackageDao.update(tbPackage);
        return this.queryById(tbPackage.getPackageId());
    }

    /**
     * 通过主键删除数据
     *
     * @param packageId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer packageId) {
        return this.tbPackageDao.deleteById(packageId) > 0;
    }
}
